<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
                <el-form-item label="用户ID">
                    <el-input
                            class="w-[150px]"
                            v-model="queryParams.uuid"
                            placeholder="请输入用户ID"
                            clearable
                            @keyup.enter="resetPage"
                    />
                </el-form-item>
                <el-form-item label="用户昵称/手机号">
                    <el-input
                            class="w-[280px]"
                            v-model="queryParams.user_keyword"
                            placeholder="请输入用户昵称/手机号"
                            clearable
                            @keyup.enter="resetPage"
                    />
                </el-form-item>
                <el-form-item label="金额类型">
                    <el-select class="w-[280px]" v-model="queryParams.type" clearable>
                        <template v-for="item in optionsData.lists.list">
                            <el-option :value="item.type" :label="item.name">{{item.name}}</el-option>
                        </template>
                    </el-select>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input
                            class="w-[280px]"
                            v-model="queryParams.content"
                            placeholder="请输入用户ID/昵称/手机号"
                            clearable
                            @keyup.enter="resetPage"
                    />
                </el-form-item>
                <el-form-item label="创建时间">
                    <daterange-picker
                            v-model:startTime="queryParams.start_time"
                            v-model:endTime="queryParams.end_time"
                    >
                    </daterange-picker>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="!border-none mt-4" shadow="never">
            <el-table size="large" v-loading="pager.loading" :data="pager.lists" style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" />
                <el-table-column label="用户信息" prop="uuid" min-width="200">
                    <template #default="{ row }">
                        <div>ID：{{ row.uuid }}</div>
                        <div>名称：{{ row.nickname }}</div>
                        <div>手机号：{{ row.phone }}</div>
                    </template>
                </el-table-column>
                <el-table-column label="操作金额" prop="name" min-width="120">
                    <template #default="{ row }">
                        {{ row.price }}
                    </template>
                </el-table-column>
               
                <el-table-column label="操作前金额" prop="name" min-width="120">
                    <template #default="{ row }">
                        {{ row.before }}
                    </template>
                </el-table-column>
                <el-table-column label="操作后金额" prop="name" min-width="120">
                    <template #default="{ row }">
                        {{ row.after }}
                    </template>
                </el-table-column>
                <el-table-column label="金额类型" prop="name" min-width="120">
                    <template #default="{ row }">
                        {{optionsData?.lists?.list.find(res => res.type == row.type).name}}
                    </template>
                </el-table-column>
                <el-table-column label="创建时间" prop="name" min-width="180">
                    <template #default="{ row }">
                        {{ row.created_at }}
                    </template>
                </el-table-column>
                <el-table-column label="备注" prop="name" min-width="180">
                    <template #default="{ row }">
                        {{ row.content }}
                    </template>
                </el-table-column>
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
    </div>
</template>
<script lang="ts" setup>
    import { getBalanceList, getRechargeType } from '@/api/finance'
    import { usePaging } from '@/hooks/usePaging'
    import feedback from "@/utils/feedback";
    import router, { getRoutePath } from '@/router'
    import {useDictOptions} from "@/hooks/useDictOptions";

    const queryParams = reactive({
        uuid: '',
        user_keyword: '',
        content: '',
        type: '',
        start_time: '',
        end_time: '',
    });

    const { pager, getLists, resetPage, resetParams } = usePaging({
        fetchFun: getBalanceList,
        params: queryParams
    });

    getLists();

    const { optionsData } = useDictOptions<{
        lists: any[]
    }>({
        lists: {
            api: getRechargeType
        }
    });


    const handleSelectionChange = (val: any) => {
        console.log(val)
        // ids.value = val.map((item: any) => {
        //     return item
        // })
    }

</script>
